<?php
/**
 * 商品管理
 *
 *
 *
 *
 * @网店运维提供技术支持 授权请购买shopnc授权
 * @license    http://www.shopwwi.com
 * @link       交流群号：111731672
 */



defined('ByShopWWI') or exit('Access Invalid!');

class order_money_exchangeModel extends Model{
    public function __construct(){
        parent::__construct('order_money_exchange');
    }

    //取得返利列表 参数 order_id goods_id
    public function getList($order_id,$goods_id) {
        $order_id=intval($order_id);
        $goods_id=intval($goods_id);
        $list=$this->table('order_money_exchange')->where(array('order_id'=>$order_id,'goods_id'=>$goods_id))->select();
        //var_dump($list);exit;
        $order_sn=$this->table('orders')->where(array('order_id'=>$order_id))->get_field('order_sn');
        foreach($list as $k=>$v){
            $list[$k]['order_sn']=$order_sn;
        }
        //var_dump($list);exit;
        return $list;
    }
    //取得返利总金额 参数 order_id goods_id
    public function getCount($order_id,$goods_id) {
        $order_id=intval($order_id);
        $goods_id=intval($goods_id);
        $list=$this->table('order_money_exchange')->where(array('order_id'=>$order_id,'goods_id'=>$goods_id))->select();
        $count=0;
        foreach($list as $k=>$v){
            $count+=$v['money_exchange'];
        }
        //var_dump($count);exit;
        return $count;
    }

}
